<?php
	class Friend_links extends CI_Model{

		function __construct(){
			parent::__construct();
		}

		function get_friend_link_list($limit = 0, $offset = 0, $conditions = array()){
			$where = "1 = 1";
			if(!empty($conditions['title']) != '') $where .= " AND title LIKE '%{$conditions['title']}%'";
			if(!empty($conditions['school_id']) != '') $where .= " AND school_id = '{$conditions['school_id']}'";
			$sql = "SELECT SQL_CALC_FOUND_ROWS * FROM {$this->db->dbprefix}o2o_school_friend_links WHERE $where ORDER BY sort DESC ";
			if($limit > 0 || $offset > 0){
				$sql .= "LIMIT $limit, $offset";
			}
			$result = $this->db->query($sql)->result_array();
			$row_num =  $this->db->query('SELECT FOUND_ROWS() as row_num;')->row_array();
			return array("count" => $row_num['row_num'], "result" => $result);
		}
	}